﻿<KCtl:BaseUserControl x:Class="Kiva7.Pages.TeamDetailControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:KCtl="clr-namespace:Kiva7.Controls"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <Grid>

        <ProgressBar Visibility="{Binding IsLoaded, Converter={StaticResource booleanToNotVisibility}}" 
                     IsIndeterminate="{Binding IsLoaded, Converter={StaticResource notBooleanConverter}}" 
                     Style="{StaticResource CustomIndeterminateProgressBar}"
                     VerticalAlignment="Center" />

        <ScrollViewer Visibility="{Binding IsLoaded, Converter={StaticResource booleanToVisibility}}" Margin="6,0,0,6">
            <Grid Background="{StaticResource KivaBackgroundBrush}" DataContext="{Binding SingleData}">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition ></ColumnDefinition>
                    <ColumnDefinition MaxWidth="200" ></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>

                <StackPanel Style="{StaticResource KivaPanelTextLargeStyle}" Grid.Row="0" Grid.ColumnSpan="2" Margin="6,0,0,6">
                    <TextBlock Text="{Binding Name}" Style="{StaticResource KivaTextLargeStyle}"
                           TextWrapping="Wrap"/>
                </StackPanel>

                <Button Click="ButtonClick" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" Margin="0,0,0,0" 
                        Background="#8074B446" Padding="0">
                    <KCtl:KivaImageControl x:Name="imgLender" ImageData="{Binding Image}" ImageSize="Normal" Width="200"  
                                Visibility="{Binding Image, Converter={StaticResource objectVisibility}}" />
                </Button>

                <StackPanel Grid.Column="0" Grid.Row="2" Style="{StaticResource KivaDetailStyle}">

                    <TextBlock x:Name="TeamId" Text="{Binding TeamId}" Visibility="Collapsed"/>

                    <TextBlock x:Name="tbkNameLabel" Text="{Binding Path=L.Name, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                       Visibility="{Binding Name, Converter={StaticResource stringVisibility}}" />
                    <TextBlock x:Name="tbkName" Text="{Binding Name}" Style="{StaticResource KivaTextAccentStyle}"
                                       TextWrapping="Wrap"
                       />

                    <TextBlock x:Name="tbkMemberSinceLabel" Text="{Binding Path=L.TeamSince, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                    <TextBlock x:Name="tbkMemberSince" Text="{Binding TeamSince, Converter={StaticResource toShortDate}}" 
                                    Style="{StaticResource KivaTextAccentStyle}"
                                    Visibility="{Binding MemberSince, Converter={StaticResource dateTimeVisibility}}"/>

                    <TextBlock x:Name="tbkWhereAboutsLabel" Text="{Binding Path=L.WhereAbouts, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding WhereAbouts, Converter={StaticResource stringVisibility}}" />
                    <TextBlock x:Name="tbkWhereAbouts" 
                                       Text="{Binding WhereAbouts}" 
                                       Style="{StaticResource KivaTextAccentStyle}"
                                       TextWrapping="Wrap"/>


                    <TextBlock Text="{Binding Path=L.Url, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding WebsiteUrl, Converter={StaticResource stringVisibility}}"/>
                    <TextBlock Text="{Binding WebsiteUrl}" Style="{StaticResource KivaTextAccentStyle}" 
                                Visibility="{Binding WebsiteUrl, Converter={StaticResource stringVisibility}}"
                                TextWrapping="Wrap"/>

                </StackPanel>
                <StackPanel Grid.Column="1" Grid.Row="2" Style="{StaticResource KivaDetailStyle}">
                    <TextBlock Text="{Binding Path=L.Loans, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                    <TextBlock Text="{Binding LoanCount}" Style="{StaticResource KivaTextAccentStyle}"/>

                    <TextBlock Text="{Binding Path=L.Amount, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                    <TextBlock Text="{Binding LoanedAmount, Converter={StaticResource toAmount}}" Style="{StaticResource KivaTextAccentStyle}"/>

                    <TextBlock Text="{Binding Path=L.Members, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"/>
                    <TextBlock Text="{Binding MemberCount}" Style="{StaticResource KivaTextAccentStyle}"/>

                    <TextBlock Text="{Binding Path=L.Membership, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding MembershipType, Converter={StaticResource stringVisibility}}" />
                    <TextBlock  Text="{Binding MembershipType}" 
                                Visibility="{Binding MembershipType, Converter={StaticResource stringVisibility}}"
                                Style="{StaticResource KivaTextAccentStyle}"
                                TextWrapping="Wrap"/>

                    <TextBlock Text="{Binding Path=L.Category, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding Category, Converter={StaticResource stringVisibility}}" />
                    <TextBlock Text="{Binding Category}" 
                                Style="{StaticResource KivaTextAccentStyle}"
                                Visibility="{Binding Category, Converter={StaticResource stringVisibility}}" 
                                       TextWrapping="Wrap"/>

                </StackPanel>

                <StackPanel Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Style="{StaticResource KivaDetailStyle}">
                    
                    <TextBlock x:Name="tbkLoanBecauseLabel" Text="{Binding Path=L.LoanBecause, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding LoanBecause, Converter={StaticResource stringVisibility}}"/>
                    <KCtl:TranslationControl  x:Name="tbkLoanBecause" 
                                       DataContext="{Binding LoanBecauseTranslation}" 
                                       TextStyle="{StaticResource KivaTextAccentStyle}"
                                       Visibility="{Binding LoanBecause, Converter={StaticResource stringVisibility}}"/>

                    <TextBlock Text="{Binding Path=L.Description, Source={StaticResource L}}"  Style="{StaticResource KivaTextNormalStyle}"
                                Visibility="{Binding Description, Converter={StaticResource stringVisibility}}" />
                    <KCtl:TranslationControl x:Name="tbDescriptionTranslation"
                        DataContext="{Binding DescriptionTranslation}" 
                                       TextStyle="{StaticResource KivaTextAccentStyle}"
                                Visibility="{Binding Description, Converter={StaticResource stringVisibility}}"/>                     
                </StackPanel>

            </Grid>
        </ScrollViewer>
    </Grid>
</KCtl:BaseUserControl>
